package com.scy.controller;

import com.scy.common.Result;
import com.scy.dto.params.LoginParam;
import com.scy.entity.User;
import com.scy.service.LoginService;
import com.scy.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * 本类用来演示
 *
 * @author wwh
 * @date 2024/6/29 11:32 $
 */
@Slf4j
@Controller
@Api(tags = "公共接口")
public class CommonController {

    @Resource
    UserService userService;
    @Resource
    LoginService loginService;

    @GetMapping("/login")
    @ApiOperation(value = "登录的页面入口")
    public String pageLogin(){
        return "common/login.html";
    }

    @ApiOperation(value = "登录信息提交")
    @PostMapping("/login")
    @ResponseBody

    public Result login(@RequestBody LoginParam loginParam) throws Exception {


        return loginService.login(loginParam);

    }

    @GetMapping("/register")
    public String pageRegister(){
        return "common/register.html";
    }

}
